#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
string s;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
    	int n;
    	cin>>n;
    	cin>>s;
    	int ans=0;
    	for(int i=0;i<n;i++)
    	{
    		int len=1;
    		int j=i+1;
    		while(j<=n && s[j]==s[i])
    		{
    			j++;
    			len++;
			}
			i=j-1;
			ans=max(len,ans);
		}
		cout<<ans+1<<endl;
	}
 
	return 0;
}
